<template>
	<view>
		<!-- 答题组件 -->
		<kz-question mode="VIEW" title="我的错题" :questions="list" v-show="!showNodata" :canDeleteWrong="false" @refresh="refresh"></kz-question>
		
		<!-- 暂无数据 -->
		<tui-no-data imgUrl="/static/img/img_noorder_3x.png" v-if="showNodata">暂无数据</tui-no-data>
		
		<login ref="login" @succ="succ"></login>
	</view>
</template>

<script>
	import { getQuestionDeatil } from '@/api/index.js'
	export default {
		data() {
			return {
				list: [],
				total: 0,
				page: 1,
				over: 0,
				questionIds:null,
				showNodata: false,
			}
		},
		onLoad(e) {
			this.questionIds = e.question_ids
		},
		onShow() {
			if (uni.getStorageSync('token')) {
				this.isLogin = true
			} else {
				  
				this.$nextTick(() => {
					this.$refs.login.modal = true;
				})
			}
			this.succ()
		},
		methods: {
			// ajax() {
			// 	this.http('question/wrongList', {page:this.page, question_ids: this.questionIds}, 'post').then(res => {
			// 		if (res.code == 0) {
			// 			this.utils.toast(res.msg)
			// 			setTimeout(() => {
			// 				this.utils.goto('/pages/user/member-center')
			// 			}, 2000)
			// 			// this.utils.confirm()
			// 			return
			// 		}
					
			// 		this.total = res.data.total;
			// 		// this.choice[2] = res.data.total;
			// 		var list = res.data.list.data;
			// 		for (var i in list) {
			// 			list[i]['log_id'] = list[i]['id']
			// 			list[i] = Object.assign(list[i], list[i]['question']);
			// 		}
					
			// 		this.list = this.list || [];
			// 		this.list = this.list.concat(list);
			// 		this.page++;
					
			// 		if (!res.data.list.has_more) {
			// 			this.over = 1;
			// 		}
					
			// 		this.showNodata = this.list.length == 0
			// 	});
			// },
			succ(){
				getQuestionDeatil({id:this.questionIds}).then((res)=>{
					if(res.data.code == 1){
								this.total = res.data.data.nums;
						// 		// this.choice[2] = res.data.total;
								var list = res.data.data.data;
								// for (var i in list) {
								// 	list[i]['log_id'] = list[i]['id']
								// 	list[i] = Object.assign(list[i], list[i]['question']);
								// }
								
								// this.list = this.list || [];
								// this.list = this.list.concat(list);
								this.list = list

								// this.page++;
								
						// 		if (!res.data.list.has_more) {
						// 			this.over = 1;
						// 		}
								
						// 		this.showNodata = this.list.length == 0
					}
				}).catch((error)=>{
					console.log(error);
				})
			},
			refresh() {
				this.page = 1
				this.list = []
				// this.ajax()
			}
		}
	}
</script>

<style>

</style>
